/**
 * @file app store
 * @author
 */

import http from '@/api';
import queryString from 'query-string';

// 后端地址环境变量
const BACKEND_API_PREFIX = process.env.BK_BACKEND_API_PREFIX;

export default {
  namespaced: true,
  state: {},
  mutations: {},
  actions: {
    getTableData(context, params, config = {}) {
      // eslint-disable-next-line no-undef
      return http.get(`/api/table?&${queryString.stringify(params)}`, params, config);
    },
    getBizData(context, params, config = {}) {
      return http.get(`${BACKEND_API_PREFIX}/biz-list/`, {}, config);
    },
    getSetData(context, params, config = {}) {
      return http.get(`${BACKEND_API_PREFIX}/set-list?${queryString.stringify(params)}`, {}, config);
    },
    getModuleData(context, params, config = {}) {
      return http.get(`${BACKEND_API_PREFIX}/module-list?${queryString.stringify(params)}`, {}, config);
    },
    getHostData(context, params, config = {}) {
      return http.get(`${BACKEND_API_PREFIX}/host-list?${queryString.stringify(params)}`, {}, config);
    },
    getHostDetail(context, params, config = {}) {
      return http.get(`${BACKEND_API_PREFIX}/host-detail?${queryString.stringify(params)}`, {}, config);
    },
  },
};
